package com.wiim.ui;

import java.util.ArrayList;

import com.wiim.adapter.DanhSachAdapter;
import com.wiim.model.DanhSachModel;
import com.wiim.nhapnhap.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

public class DanhSachFragment extends Fragment {
	private ListView lvDanhSach;
	private DanhSachAdapter dataAdapter;
	ArrayList<DanhSachModel> datalist;

	@Override
	public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.danhsach_list, container, false);
		initFeld(view);
		initData();
		return view;
	}

	private void initFeld(View view) {
		lvDanhSach = (ListView) view.findViewById(R.id.lvDanhSach);

		 datalist= new ArrayList<DanhSachModel>();
		for (int i = 0; i < 20; i++) {
			DanhSachModel ds=new DanhSachModel("Cua Hang "+i, "mo ta khuyen mai "+i);
			datalist.add(ds);
		}

	}

	private void initData() {
		dataAdapter=new DanhSachAdapter(getActivity(), datalist);
		lvDanhSach.setAdapter(dataAdapter);
		
	}
}
